package com.mashibing.class01;

import javax.xml.soap.Node;

/**
 * @Auther: huangxiaode
 * @Date: 2024-01-29 - 01 - 29 - 15:54
 * @Description: com.mashibing.class01
 * @version: 1.0
 */
public class Code01_SumOfFactorial {
    public static long f1(int N){
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            ans += factorial(i);
        }
        return ans;
    }

    private static long factorial(int N) {
        long ans = 1;
        for (int i = 1; i <= N; i++) {
            ans *= i;
        }
        return ans;
    }

    public static  long f2 (int N){
        long ans = 0;
        long cur = 1;
        for (int i = 1; i < N; i++) {
            cur = cur * i;
            ans += cur;
        }
        return ans;
    }

    public static void main(String[] args) {
        long ans = f2(10);
        System.out.println("ans = " + ans);
    }
}
